// Key Driver
// (c) jimon game studio

#ifndef JEH_CKEYDRIVER
#define JEH_CKEYDRIVER

#include "IKeyDriver.h"
#include "IWindow.h"

namespace je
{
	namespace input
	{
		//! Key Driver
		class CKeyDriver:public je::input::IKeyDriver
		{
		protected:
			device::IWindow * Window;

			u1 KeyDown[256];
			u1 KeyDownMessages[256];
			s32 KeyHits[256];
			s32 KeyHitsFlush[256];

			jeDynamicArray<KeyCode> KeyStream;

		public:
			//! Constructor
			CKeyDriver(device::IWindow * window);

			//! Destructor
			~CKeyDriver();

			//! Return true if hit
			u1 IsHit(KeyCode Key);

			//! Return true if down
			u1 IsDown(KeyCode Key,u1 TrueWhenDownMessageArrive = false);

			//! Flush Keys Hits
			void FlushKeysHits();

			//! Get Keys Stream, last element of stream is KC_NULL
			KeyCode * GetKeysStream();

			//! Get Text Stream
			jeStringd GetTextStream();

			//! Flush Keys Stream
			void FlushKeysStream();

			//! Set Down
			void SetDown(KeyCode Key,u1 Down);
		};
	}
}

#endif
